import { ref } from 'vue';
import { defineStore } from 'pinia';

export const useThemeStore = defineStore('theme', () => {
    
    // 是否启用主题
    const themeFlag = ref(JSON.parse(localStorage.getItem('themeFlag') || '{}'));

    // 启用主题事件
    const changeTheme = (b: Boolean) => {
        themeFlag.value = b;
        localStorage.setItem('themeFlag', String(b));
    }

    return { themeFlag, changeTheme };
});